package com.julian.iteratorPattern;

import java.util.ArrayList;
import java.util.Iterator;

public class Waitress {
    Menu pancakeHouseMenu;
    Menu dinMenu;
    Menu cafeMenu;

    ArrayList menus;

    public Waitress(ArrayList menus) {
        this.menus = menus;
    }

    public Waitress(Menu pancakeHouseMenu, Menu dinMenu, Menu cafeMenu) {
        this.pancakeHouseMenu = pancakeHouseMenu;
        this.dinMenu = dinMenu;
        this.cafeMenu = cafeMenu;
    }

    public void printMenu(){
        Iterator pancakeIterator = pancakeHouseMenu.createIterator();
        Iterator dinnerIterator = dinMenu.createIterator();
        Iterator cafeIterator = cafeMenu.createIterator();
        System.out.println("Menu\n----\nBREAKFAST");
        printMenu(pancakeIterator);
        System.out.println("\nLUNCH\n----\n");
        printMenu(dinnerIterator);
        System.out.println("\nDinner\n---\n");
        printMenu(cafeIterator);
    }

    public void printMenu2(){
        Iterator menuIterator = menus.iterator();
        while (menuIterator.hasNext()){
            Menu menu = (Menu)menuIterator.next();
            printMenu(menu.createIterator());
        }
    }

    private void printMenu(Iterator iterator){
        while (iterator.hasNext()){
            MenuItem menuItem = (MenuItem)iterator.next();
            System.out.println(menuItem.getName() + ",");
            System.out.println(menuItem.getDescription() + ",");
            System.out.println(menuItem.getPrice() + ",");
        }
    }
}
